home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / CIncludes / QD3DSet.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-12  |  10.6 KB  |  333 lines  |  [TEXT/MPS ]

  1. /******************************************************************************
  2.  **                                                                             **
  3.  **     Module:        QD3DSet.h                                                 **
  4.  **                                                                             **
  5.  **                                                                             **
  6.  **     Purpose:     Set types and routines                                     **
  7.  **                                                                             **
  8.  **                                                                             **
  9.  **                                                                             **
  10.  **     Copyright (C) 1992-1997 Apple Computer, Inc.  All rights reserved.     **
  11.  **                                                                             **
  12.  **                                                                             **
  13.  *****************************************************************************/
  14. #ifndef QD3DSet_h
  15. #define QD3DSet_h
  16.  
  17. #include "QD3D.h"
  18.  
  19. #if defined(PRAGMA_ONCE) && PRAGMA_ONCE
  20.     #pragma once
  21. #endif  /*  PRAGMA_ONCE  */
  22.  
  23. #if defined(OS_MACINTOSH) && OS_MACINTOSH
  24.  
  25. #if defined(__xlc__) || defined(__XLC121__)
  26.     #pragma options enum=int
  27.     #pragma options align=power
  28. #elif defined(__MWERKS__)
  29.     #pragma enumsalwaysint on
  30.     #pragma options align=native
  31. #elif defined(__MRC__) || defined(__SC__)
  32.     #if __option(pack_enums)
  33.         #define PRAGMA_ENUM_RESET_QD3DSET 1
  34.     #endif
  35.     #pragma options(!pack_enums)
  36.     #pragma options align=power
  37. #endif
  38.  
  39. #endif  /* OS_MACINTOSH */
  40.  
  41. #ifdef __cplusplus
  42. extern "C" {
  43. #endif    /* __cplusplus */
  44.  
  45.  
  46. /******************************************************************************
  47.  **                                                                             **
  48.  **                                Set Routines                                 **
  49.  **                                                                             **
  50.  *****************************************************************************/
  51.  
  52. QD3D_EXPORT TQ3SetObject QD3D_CALL Q3Set_New(
  53.     void);
  54.  
  55. QD3D_EXPORT TQ3ObjectType QD3D_CALL Q3Set_GetType(
  56.     TQ3SetObject        set);
  57.  
  58. QD3D_EXPORT TQ3Status QD3D_CALL Q3Set_Add(
  59.     TQ3SetObject         set, 
  60.     TQ3ElementType        type,
  61.     const void             *data);
  62.  
  63. QD3D_EXPORT TQ3Status QD3D_CALL Q3Set_Get(
  64.     TQ3SetObject         set,
  65.     TQ3ElementType        type,
  66.     void                *data);
  67.  
  68. QD3D_EXPORT TQ3Boolean QD3D_CALL Q3Set_Contains(
  69.     TQ3SetObject         set,
  70.     TQ3ElementType        type);
  71.  
  72. QD3D_EXPORT TQ3Status QD3D_CALL Q3Set_Clear(
  73.     TQ3SetObject         set, 
  74.     TQ3ElementType        type);
  75.  
  76. QD3D_EXPORT TQ3Status QD3D_CALL Q3Set_Empty(
  77.     TQ3SetObject         target);
  78.  
  79. /*
  80.  *  Iterating through all elements in a set
  81.  *
  82.  *  Pass in kQ3ElementTypeNone to get first type
  83.  *  kQ3ElementTypeNone is returned when end of list is reached
  84.  */
  85. QD3D_EXPORT TQ3Status QD3D_CALL Q3Set_GetNextElementType(
  86.     TQ3SetObject         set,
  87.     TQ3ElementType        *type);        
  88.  
  89.  
  90. /******************************************************************************
  91.  **                                                                             **
  92.  **                                Attribute Types                                 **
  93.  **                                                                             **
  94.  *****************************************************************************/
  95.  
  96. /* 
  97.  *    For the data types listed below, pass in a pointer to it in the _Add 
  98.  *    and _Get calls.
  99.  *
  100.  *    For surface shader attributes, reference counts are incremented on 
  101.  *    the _Add and _Get 
  102.  */
  103.  
  104. typedef enum TQ3AttributeTypes {                /* Data Type                */
  105.     kQ3AttributeTypeNone                =  0,    /* ---------                */
  106.     kQ3AttributeTypeSurfaceUV            =  1,    /* TQ3Param2D                */ 
  107.     kQ3AttributeTypeShadingUV            =  2,    /* TQ3Param2D                 */
  108.     kQ3AttributeTypeNormal                =  3,    /* TQ3Vector3D                 */
  109.     kQ3AttributeTypeAmbientCoefficient    =  4,    /* float                     */
  110.     kQ3AttributeTypeDiffuseColor        =  5,    /* TQ3ColorRGB                */
  111.     kQ3AttributeTypeSpecularColor        =  6,    /* TQ3ColorRGB                */
  112.     kQ3AttributeTypeSpecularControl        =  7,    /* float                    */
  113.     kQ3AttributeTypeTransparencyColor    =  8,    /* TQ3ColorRGB                */
  114.     kQ3AttributeTypeSurfaceTangent        =  9,    /* TQ3Tangent2D              */
  115.     kQ3AttributeTypeHighlightState        = 10,    /* TQ3Switch                 */
  116.     kQ3AttributeTypeSurfaceShader        = 11,    /* TQ3SurfaceShaderObject    */
  117.     kQ3AttributeTypeNumTypes
  118. } TQ3AttributeTypes;
  119.  
  120. typedef TQ3ElementType TQ3AttributeType;
  121.  
  122.  
  123. /******************************************************************************
  124.  **                                                                             **
  125.  **                                Attribute Drawing                             **
  126.  **                                                                             **
  127.  *****************************************************************************/
  128.  
  129. QD3D_EXPORT TQ3Status QD3D_CALL Q3Attribute_Submit(
  130.     TQ3AttributeType        attributeType,
  131.     const void                *data,
  132.     TQ3ViewObject            view);
  133.  
  134.  
  135. /******************************************************************************
  136.  **                                                                             **
  137.  **                            AttributeSet Routines                             **
  138.  **                                                                             **
  139.  *****************************************************************************/
  140.  
  141. QD3D_EXPORT TQ3AttributeSet QD3D_CALL Q3AttributeSet_New(
  142.     void);
  143.  
  144. QD3D_EXPORT TQ3Status QD3D_CALL Q3AttributeSet_Add(
  145.     TQ3AttributeSet         attributeSet, 
  146.     TQ3AttributeType        type,
  147.     const void                 *data);
  148.  
  149. QD3D_EXPORT TQ3Boolean QD3D_CALL Q3AttributeSet_Contains(
  150.     TQ3AttributeSet            attributeSet,
  151.     TQ3AttributeType        attributeType);
  152.  
  153. QD3D_EXPORT TQ3Status QD3D_CALL Q3AttributeSet_Get(
  154.     TQ3AttributeSet         attributeSet,
  155.     TQ3AttributeType        type,
  156.     void                    *data);
  157.  
  158. QD3D_EXPORT TQ3Status QD3D_CALL Q3AttributeSet_Clear(
  159.     TQ3AttributeSet         attributeSet,
  160.     TQ3AttributeType        type);
  161.  
  162. QD3D_EXPORT TQ3Status QD3D_CALL Q3AttributeSet_Empty(
  163.     TQ3AttributeSet         target);
  164.  
  165. /*
  166.  * Q3AttributeSet_GetNextAttributeType
  167.  *
  168.  * Pass in kQ3AttributeTypeNone to get first type
  169.  * kQ3AttributeTypeNone is returned when end of list is reached
  170.  */
  171. QD3D_EXPORT TQ3Status QD3D_CALL Q3AttributeSet_GetNextAttributeType(
  172.     TQ3AttributeSet         source,
  173.     TQ3AttributeType        *type);        
  174.  
  175. QD3D_EXPORT TQ3Status QD3D_CALL Q3AttributeSet_Submit(
  176.     TQ3AttributeSet            attributeSet, 
  177.     TQ3ViewObject            view);
  178.  
  179. /*
  180.  * Inherit from parent->child into result
  181.  *    Result attributes are:
  182.  *        all child attributes + all parent attributes NOT in the child
  183.  */
  184. QD3D_EXPORT TQ3Status QD3D_CALL Q3AttributeSet_Inherit(
  185.     TQ3AttributeSet            parent, 
  186.     TQ3AttributeSet            child, 
  187.     TQ3AttributeSet            result);
  188.  
  189.  
  190. /******************************************************************************
  191.  **                                                                             **
  192.  **                            Custom Element Registration                         **
  193.  **                                                                             **
  194.  *****************************************************************************/
  195.  
  196. /*
  197.  * Element Methods - 
  198.  *
  199.  *         When you create a custom element, you control what structures are 
  200.  *        passed around the API. For example, you may allow the Q3Set_Add call 
  201.  *        take one type of argument, store your element internally in some 
  202.  *        abstract data type, and have the Q3Set_Get call take a different 
  203.  *        argument.
  204.  *
  205.  *        For example:
  206.  *            
  207.  *        There are four calls which at some point will copy an element:
  208.  *
  209.  *        Q3Set_Add (copied from Application memory to QuickDraw3D memory)
  210.  *        Q3Set_Get (copied from QuickDraw3D memory to Application memory)
  211.  *        Q3Object_Duplicate (all elements are copied internally)
  212.  *        Q3AttributeSet_Inherit (all elements are copied internally)
  213.  *
  214.  *         Either CopyAdd or CopyReplace is called during the "_Add" call.
  215.  *            - CopyAdd is destructive and should assume "toElement" is garbage
  216.  *            - CopyReplace is replacing an existing element.
  217.  *
  218.  *         CopyGet is called during the "_Get" call.
  219.  *
  220.  *         CopyDuplicate is called to duplicate an element's internal structure.
  221.  *
  222.  * Attributes Methods - 
  223.  *
  224.  *        For copying data while Inheriting. Element methods are used
  225.  *        at all other times.
  226.  *    
  227.  *         CopyInherit is called to duplicate an element's internal structure 
  228.  *            during inheritance. You should make this as fast as possible.
  229.  *            (for example, if your custom element contains objects, you
  230.  *             should do a Q3Shared_GetReference instead of a Q3Object_Duplicate)
  231.  *            
  232.  *        The ElementDelete method will be called for all of your elements 
  233.  *        copied around via CopyAdd, CopyReplace, CopyDuplicate, and 
  234.  *        CopyInherit.
  235.  *        If CopyGet allocates any memory in it's destination, it is up to the 
  236.  *        application to delete it on its side.
  237.  */
  238.  
  239.  
  240.  
  241. #define kQ3XMethodTypeElementCopyAdd        Q3_METHOD_TYPE('e','c','p','a')
  242. #define kQ3XMethodTypeElementCopyReplace    Q3_METHOD_TYPE('e','c','p','r')
  243. #define kQ3XMethodTypeElementCopyGet        Q3_METHOD_TYPE('e','c','p','g')
  244. #define kQ3XMethodTypeElementCopyDuplicate    Q3_METHOD_TYPE('e','c','p','d')
  245. #define kQ3XMethodTypeElementDelete            Q3_METHOD_TYPE('e','d','e','l')
  246.  
  247. typedef TQ3Status (QD3D_CALLBACK *TQ3XElementCopyAddMethod)(    
  248.     const void            *fromAPIElement,            /* element from _Add API call */
  249.     void                *toInternalElement);        /* to new QD3D internal element */
  250.  
  251. typedef TQ3Status (QD3D_CALLBACK *TQ3XElementCopyReplaceMethod)(
  252.     const void            *fromAPIElement,            /* element from _Add API call */
  253.     void                *ontoInternalElement);        /* replacing QD3D internal element */
  254.  
  255. typedef TQ3Status (QD3D_CALLBACK *TQ3XElementCopyGetMethod)(
  256.     const void            *fromInternalElement,        /* from QD3D internal element */
  257.     void                *toAPIElement);                /* to _Get API call */
  258.  
  259. typedef TQ3Status (QD3D_CALLBACK *TQ3XElementCopyDuplicateMethod)(
  260.     const void            *fromInternalElement,        /* from QD3D internal element */
  261.     void                *toInternalElement);        /* to new QD3D internal element */
  262.  
  263. typedef TQ3Status (QD3D_CALLBACK *TQ3XElementDeleteMethod)(    
  264.     void                *internalElement);
  265.  
  266. QD3D_EXPORT TQ3XObjectClass QD3D_CALL Q3XElementClass_Register(
  267.      TQ3ElementType        *elementType,
  268.     const char            *name,
  269.     unsigned long        sizeOfElement,
  270.     TQ3XMetaHandler        metaHandler);
  271.  
  272. QD3D_EXPORT TQ3Status QD3D_CALL Q3XElementType_GetElementSize(
  273.      TQ3ElementType        elementType,
  274.     unsigned long        *sizeOfElement);
  275.  
  276.  
  277. /******************************************************************************
  278.  **                                                                             **
  279.  **                        Custom Attribute Registration                         **
  280.  **                                                                             **
  281.  *****************************************************************************/
  282.  
  283. #define kQ3XMethodTypeAttributeInherit        Q3_METHOD_TYPE('i','n','h','t')
  284. typedef TQ3Boolean        TQ3XAttributeInheritMethod;
  285. /* return kQ3True or kQ3False in your metahandler */
  286.  
  287. #define kQ3XMethodTypeAttributeCopyInherit    Q3_METHOD_TYPE('a','c','p','i')
  288. typedef TQ3Status (QD3D_CALLBACK *TQ3XAttributeCopyInheritMethod)(
  289.     const void            *fromInternalAttribute,        /* from QD3D internal element */
  290.     void                *toInternalAttribute);        /* to new QD3D internal element */
  291.  
  292. QD3D_EXPORT TQ3XObjectClass QD3D_CALL Q3XAttributeClass_Register(
  293.     TQ3AttributeType    *attributeType,
  294.     const char            *creatorName,
  295.     unsigned long        sizeOfElement,
  296.     TQ3XMetaHandler        metaHandler);
  297.  
  298. /*
  299.  *    Version 1.1
  300.  */
  301. #define kQ3XMethodTypeAttributeDefault        Q3_METHOD_TYPE('a','s','d','f')
  302. typedef TQ3Status (QD3D_CALLBACK *TQ3XAttributeDefaultMethod)(    
  303.     void                *internalElement);
  304.  
  305. #define kQ3XMethodTypeAttributeIsDefault    Q3_METHOD_TYPE('a','i','d','f')
  306. typedef TQ3Boolean (QD3D_CALLBACK *TQ3XAttributeIsDefaultMethod)(    
  307.     void                *internalElement);
  308.  
  309.  
  310. #ifdef __cplusplus
  311. }
  312. #endif    /* __cplusplus */
  313.  
  314. #if defined(OS_MACINTOSH) && OS_MACINTOSH
  315.  
  316. #if defined(__xlc__) || defined(__XLC121__)
  317.     #pragma options enum=reset
  318.     #pragma options align=reset
  319. #elif defined(__MWERKS__)
  320.     #pragma enumsalwaysint reset
  321.     #pragma options align=reset
  322. #elif defined(__MRC__) || defined(__SC__)
  323.     #if PRAGMA_ENUM_RESET_QD3DSET
  324.         #pragma options(pack_enums)
  325.         #undef PRAGMA_ENUM_RESET_QD3DSET
  326.     #endif
  327.     #pragma options align=reset
  328. #endif
  329.  
  330. #endif  /* OS_MACINTOSH */
  331.  
  332. #endif /*  QD3DSet_h */
  333.